public class Search {
    public int search(int[] nums, int target) {
        // 定义两个指针
        int i = 0, j = nums.length - 1;
        while (i <= j) {
            int m = (i + j) >>> 1;
            if (nums[m] < target){
                i = m + 1;
            } else if (target < nums[m]){
                j = m - 1;
            } else {
                return m;
            }
        }
        return -1;
    }
}
